﻿using Journal.Domain.IDomainServices;
using Journal.Domain.Models;
using Journal.Front.Presentation.Mappers;
using Journal.Front.Presentation.Models.UserModels;
using Journal.Front.Presentation.PresentationServicesInterfaces;

namespace Journal.Front.Presentation.PresentationServices
{
    public class UserPresentationService : IUserPresentationService
    {
        private readonly IUserDomainService userDomainService;
        private readonly IRoleDomainService roleDomainService;

        public UserPresentationService(IUserDomainService userDomainService, IRoleDomainService roleDomainService)
        {
            this.userDomainService = userDomainService;
            this.roleDomainService = roleDomainService;
        }

        public UserEditModel GetUserEditModel(int id)
        {
            User user = userDomainService.Get(id);
            return new UserEditModel(user);
        }

        public void Save(UserEditModel model)
        {
            User user = userDomainService.Get(model.Id);
            model.MapTo(user);
            userDomainService.Save(user);
        }
    }
}